package com.alinesno.cloud.initializr.starter.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.alinesno.cloud.common.core.service.impl.IBaseServiceImpl;
import com.alinesno.cloud.initializr.starter.entity.InitializrJavaVersionEntity;
import com.alinesno.cloud.initializr.starter.repository.InitializrJavaVersionRepository;
import com.alinesno.cloud.initializr.starter.service.IInitializrJavaVersionService;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2020-11-20 10:06:08
 */
@Service
public class InitializrJavaVersionServiceImpl
		extends IBaseServiceImpl<InitializrJavaVersionEntity, InitializrJavaVersionRepository>
		implements IInitializrJavaVersionService {

	// 日志记录
	@SuppressWarnings("unused")
	private static final Logger log = LoggerFactory.getLogger(InitializrJavaVersionServiceImpl.class);

	@Override
	public boolean save(InitializrJavaVersionEntity entity) {
		final int activeDefault = 1;
		if (activeDefault == entity.getIsActive()) {
			mapper.reverseDefaultActive();
		}
		return super.save(entity);
	}

	@Override
	public void update(InitializrJavaVersionEntity entity) {
		final int activeDefault = 1;
		if (activeDefault == entity.getIsActive()) {
			mapper.reverseDefaultActive();
		}
		super.update(entity);
	}
}
